<template>
  <div class="personal_purse">
    <!-- <my-header :showBack="true" title="奖金"></my-header> -->
		<div class="ass_top">
      <div class="head_top">
        <div>
          <i class="iconfont icon-caidan1 menu"  @click="showProp"></i>
        </div>
        <div>{{$t("lang.Formacoassets")}}</div>
        <div class="rightmenu">
          <!--  -->
        </div>
      </div>
    <div class="all_ass">
      <p>{{$t("lang.DynamicAss")}}：<b>{{AssetNUM.dynamicMoney.toFixed(3)||"0.00"}}</b></p>
      <p>{{$t("lang.StaticAsse")}}：<b>{{AssetNUM.staticMoney.toFixed(3)||"0.00"}}</b></p>
    </div>
    </div>
    <div class="prolist">
		<!-- 02 -->
    <van-tabs v-model="active" sticky>
      <van-tab :title="$t('lang.DynamicAss')" >
        <van-list v-show="recordList.length>0" v-model="loading" :finished="finished" @load="loadMore" :offset="10" class="trad_list"> 
			  <ul >
				<li v-for="item in recordList" :key="item.index">
					<div slot="title" class="jytime">
						<div class="nflex">
							<!-- <h3>交易编号:JY5159</h3> -->
							<p>{{$t("lang.C2Ctype")}}：<span>{{item.profitZhRemark}}</span></p>
							<!--profitStatus 1 收入 2 支出 -->
							<p class="tipgren" v-if="item.profitStatus==2">-{{parseFloat(item.profitNum).toFixed(4)}}</p>
							<p class="tipred" v-if="item.profitStatus==1">+{{parseFloat(item.profitNum).toFixed(4)}}</p>
						</div>
						<div class="nflex">
							<p>{{$t("lang.Time")}}：{{item.createTime}}</p>
						</div>
					</div>
				</li>
			</ul>
      </van-list>
      <div class="no_data" v-show="recordList.length==0"><img src="../../assets/img/my/nodata.png" alt="" srcset="">{{$t("lang.NoData")}}</div>
      </van-tab>
      <van-tab :title="$t('lang.StaticAsse')">
        <van-list v-show="recordList.length>0" v-model="loading" :finished="finished" @load="loadMore" :offset="10" class="trad_list"> 
			  <ul >
				<li v-for="item in recordList" :key="item.index">
					<div slot="title" class="jytime">
						<div class="nflex">
							<!-- <h3>交易编号:JY5159</h3> -->
							<p>{{$t("lang.C2Ctype")}}：<span>{{item.profitZhRemark}}</span></p>
							<!--profitStatus 1 收入 2 支出 -->
							<p class="tipgren" v-if="item.profitStatus==2">-{{parseFloat(item.profitNum).toFixed(4)}}</p>
							<p class="tipred" v-if="item.profitStatus==1">+{{parseFloat(item.profitNum).toFixed(4)}}</p>
						</div>
						<div class="nflex">
							<p>{{$t("lang.Time")}}：{{item.createTime}}</p>
						</div>
					</div>
				</li>
			</ul>
      </van-list>
      <div class="no_data" v-show="recordList.length==0"><img src="../../assets/img/my/nodata.png" alt="" srcset="">{{$t("lang.NoData")}}</div>
      </van-tab>
    </van-tabs>
    </div>
		<!-- 左侧侧滑菜单 -->
    <van-popup v-model="showLeftProp" position="left" :overlay="true" class="leftprop_box">
      <right-menu></right-menu>
    </van-popup>
  </div>
</template>

<script>
import header from "@/components/header";
import { Toast } from 'vant';
import ClipboardJS from 'Clipboard'
import RightMenu from "./RightMenu.vue";

export default {
  components: {
		"my-header": header,
		"right-menu":RightMenu,
  }, 
  data(){
    return{
			userInfo:{},

			active: 0,
			activeNames: ['0'],
			jyListData:[1,2,3,],
      showLeftProp: false,
      type:"",
      AssetNUM:[],
      loading: false,
      finished: true,
      recordList: [],
      searchData: {
        pageNo: 1, //当前页
        pageSize: 30, //每页30条
        type:"",
      },
    }
  },
  filters: {
    formatDate(time) {
      var date = new Date(time);
      return timeFormat.formatDate(date, "yyyy.MM.dd hh:mm");
    }
  },
  watch: {
    active:function(val){
      if(this.active==0){
        // 9 动态
      this.searchData.type=9;
      this.init() ;
      }else{
        // 8 静态
        this.searchData.type=8;
        this.init() ;
      }
    }
  },
  mounted(){
    this.$store.commit("updateSelected", 2);
    this.$store.commit("updateNeedShowFooter", true);
    this.selectAccount();
    // 9 动态
    this.searchData.type=9;
    this.init() ;
  },
  methods:{
		showProp(){
      this.showLeftProp=true;
    },
    closeProp(){
      this.showLeftProp=false;
    },
    selectAccount(){
      // 个人资产
      this.$ajax(this.$api.selectAccount).then(res=>{
          if(res.code==0){
            // 奖金
            this.AssetNUM=res.msg;
          }
        })
    },
    init() {
      this.searchData.pageNo = 1;
      this.$ajax(this.$api.selectProfit, this.searchData).then(res => {
        this.loading = false;
        this.recordList = [];
        if (res.code === 0) {
          if (res.msg && res.msg.list.length > 0) {
						this.recordList = res.msg.list;
            this.finished = this.searchData.pageNo == res.msg.lastPage;
            this.loading = false;
          }
        } else {
          this.recordList = [];
        }
      });
    },
    loadMore: function() {
      this.searchData.pageNo += 1;
      this.$ajax(this.$api.selectProfit, this.searchData,).then(res => {
        this.loading = false;
        this.recordList = [];
        if (res.code === 0) {
          if (res.msg && res.msg.list.length > 0) {
            this.recordList = this.recordList.concat(res.msg.list);
            this.finished = this.searchData.pageNo == res.msg.lastPage;
            this.loading = false;
          }
        }
      });
    },
  }
}
</script>

<style lang='less' scoped>
.ass_top{background: url(../../assets/img/assetIndex/grzx_dhzx.png)}
.all_ass{
  text-align: center;padding:5vh 0;
  h3{color: #E1AF56;font-size: 24px;line-height: 30px;}
	p{color: #AA7A24;padding: 5px 0;}
	b{color: #E1AF56;}
}
// head_top
.head_top{
	width: 100%;
  height: 44px;
	line-height: 44px;
  font-size: 16px;
  color: #ffffff;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  background: transparent;      
}
.head_top .menu{font-size: 20px;}
.head_top i{
  padding:10px;
  font-size: 14px;
}
.head_top div:nth-child(1) {
  width:20%;
  box-sizing: border-box;
}
.head_top div:nth-child(2) {
  width:60%;
  text-align:center;
}
.head_top div:nth-child(3) {
  width:20%;
  text-align:center;
  font-size:12px;
}
// 
.trad_list{
	background: #f6f6f6;
		box-sizing: border-box;padding:0px 12px;background:#ffffff;margin-top:0px;
		h3{color: #333333;line-height: 26px;}
		li{padding: 10px 0;border-bottom: 1px solid #eeeeee;}
		.nflex{display: flex;justify-content:space-between ;
			p{line-height: 20px;color: #999999;}
			span{color: #333333;}
			.npadd{padding: 15px 0;}
			.tiphui{color: #999999;}
			.tipred{color: #FF5458;}
			.tipgren{color: #00BA4F;}
		}
		.buybtn{color: #FF4954;border: 1px solid #FF4954;border-radius: 20px;padding: 0 6px ;}		
}
.jytime{
	h3{color: #333333;font-size: 14px;}
	p{color: #CCCCCC;}
	}
	// leftmenu prop
.leftprop_box{background: #ffffff;width:80vw;height: 100%;}
.leftprop_box h3{padding-left: 14px;font-weight: 600;}
.leftprop_title{height: 65px;line-height: 65px;border-bottom: 1px solid #eeeeee;}
.homeleft_list li{display: flex; justify-content: space-between ;align-items:center; height: 50px;line-height: 50px;padding: 0 12px;color: #333333;}
.homeleft_list li div{display: flex;align-items:center; }
.homeleft_list li img{width: 25px;height: 25px;}
.homeleft_list li p{padding-left: 10px;}
.prolist{margin-bottom: 50px;}
</style>
